package three;

import java.util.Random;
import java.util.Scanner;

public class NumGuessing {
    public static void main(String[] args) {
        System.out.println("给你一个1至100之间的整数，请猜测这个数");
        Random random = new Random();
        int num = random.nextInt(100) + 1;  // 生成1 - 100之间的随机整数
        Scanner sc = new Scanner(System.in);
        int guess = 0;
        do {
            System.out.print("输入您的猜测:");
            guess = sc.nextInt();
            if (guess > num) {
                System.out.println("猜大了,再输入你的猜测:");
            } else if (guess < num) {
                System.out.println("猜小了,再输入你的猜测:");
            } else {
                System.out.println("猜对了!");
            }
        } while (guess != num);
        sc.close();
    }
}
